<div class="header">
    <div class="w1210">
        <div class="mall-logo">
            <a href="{:U('Index/index')}"><img src="__IMG__/home/logo.png"></a>
        </div>
        <div class="mall-logo-right">
            <a href="{:U('Index/index')}" target="_blank"></a>
        </div>
        <div class="mall-search">
            <div id="search-tips" style="display: none;">
                <div onclick="setTip('收纳箱600D');" class="search_t_div_1" title="收纳箱600D">aaaa<span>119 结果</span></div>
                <label onclick="Dh('search-tips');">关闭&nbsp;&nbsp;</label>
            </div>
            <form class="mallSearch-form" method="get" name="searchForm" id="searchForm" action="{:HOME_URL}{:U('/Search/index')}" onsubmit="return checkSearchForm()">
                <input type="hidden" name="type" id="searchtype" value="0">
                <div class="mallSearch-input">
                    <ul class="search-type" style="height: 32px; overflow: hidden;">
                        <li class="cur" num="0">宝贝<i class="icon-down"></i></li>
                        <li num="1">店铺<i class="icon-down"></i></li>
                    </ul>
                    <div class="s-combobox">
                        <div class="s-combobox-input-wrap">
                            <input aria-haspopup="true" role="combobox" class="s-combobox-input" name="keys" id="keyword" tabindex="9" accesskey="s" onkeyup="search();" autocomplete="off" value="请输入关键词" onfocus="if (this.value == '请输入关键词') {
                                this.value = '';
                                    }else{
                                this.value = this.value;
                                    }" onblur="if (this.value == '')
                                this.value = '请输入关键词'" type="text">
                        </div>
                    </div>
                    <input type="submit" value="搜索" class="button main-bg-color">
                </div>
            </form>
            <ul class="hot-query">
                <foreach item='v' name='keywords' key='k'>
                    <if condition="$k eq 0">
                        <li style="border-left: none;">
                            <a href="{:HOME_URL}/Search/index.html?keys={$v['k_title']}" title="{$v['k_title']}">
                               <if condition="$v['k_strong'] eq 1">
                                    <font color="{$v['k_color']}"><b>{$v['k_title']}</b></font>
                                <else />
                                    <font color="{$v['k_color']}">{$v['k_title']}</font>
                                </if>
                            </a>
                        </li>
                    <else />
                        <li>
                            <a href="{:HOME_URL}/Search/index.html?keys={$v['k_title']}" title="{$v['k_title']}">
                                <if condition="$v['k_strong'] eq 1">
                                    <font color="{$v['k_color']}"><b>{$v['k_title']}</b></font>
                                <else />
                                    <font color="{$v['k_color']}">{$v['k_title']}</font>
                                </if>
                            </a>
                        </li>
                    </if>
                </foreach>
            </ul>
        </div>
        <if condition="($supplier)">
			<ul class="header-right" style="top: 0;">
	            <li>
	                <img src="__IMG__/home/7day.jpg">
	            </li>
	            <li>
	                <img src="__IMG__/home/guarantee.jpg">
	            </li>
	            <li>
	                <img src="__IMG__/home/delivery.jpg">
	            </li>
	        </ul>
        <else />
            <ul class="header-right">
	            <li>
	                <img src="__IMG__/home/7day.jpg">
	            </li>
	            <li>
	                <img src="__IMG__/home/guarantee.jpg">
	            </li>
	            <li>
	                <img src="__IMG__/home/delivery.jpg">
	            </li>
	            <li class="header-right_bottom">
                    <if condition="session('store_id')">
                        <a href="{$Think.STORE_URL}/Set/index">
                    <else />
                        <a href="{$Think.HOME_URL}/Storejoinin/index">
                    </if>
	                    <h3>商家入驻申请</h3>
	                    <h5>已申请可查看申请状态</h5>
	                </a>
	            </li>
	        </ul>
        </if>
    </div>
</div>
<script>
    //鼠标滑过样式
    $("#search-tips > div").hover(function () {
        $(this).attr("class", "search_t_div_2");
    }, function () {
        $(this).attr("class", "search_t_div_1");
    })
    //搜索项切换
    $('.search-type').hover(function () {
        $(this).css({
            "height": "auto",
            "overflow": "visible"
        });
    }, function () {
        $(this).css({
            "height": 32,
            "overflow": "hidden"
        });
    });
    $('.search-type li').click(function () {
        $(this).addClass('cur').siblings().removeClass('cur');
        $('#searchtype').val($(this).attr('num'));
    });
    //搜索框赋值并跳转
    function setTip(val) {
        $(".s-combobox-input").val(val);
        $("#searchForm").submit();
    }
    //关闭搜索框
    function Dh(obj) {
        $("#" + obj).hide();
        $("#" + obj).children().each(function () {
            $(this).remove();
        })
    }

    //联想搜索
    var search_times;
    function search(){
        clearInterval(search_times);
        search_times =  setTimeout(function(){search_time(search_times)},500);
    }
    function search_time(search_times) {
        clearInterval(search_times);
        var objval = $(".s-combobox-input").val();
        var objtype;
        $(".search-type li").each(function () {
            if ($(this).hasClass("cur")) {
                objtype = $(this).index();
            }
        });
        $.ajax({
            url: homeUrl+"/Index/ajax_search",
            type: "post",
            dataType:"json",
            data: {
                "objval": objval,
                "objtype": objtype
            }, //val值    查找的类型0宝贝 和 1店铺
            success: function (result) {
                if (result) {
                    $("#search-tips").children().each(function () {
                        $(this).remove();
                    });
                    $("#search-tips").show();
                    for (var i = 0; i > result.data.length; i++) {
                        var html = "<div onclick=\"setTip(\'" + result.data[i] + "\');\"class=\"search_t_div_1\" title=\"" + result.data[i] + "\">aaaa<span>" + result.num[i] + " 结果</span></div>";
                        $("#search-tips").append(html);
                    }
                } else {
                    $("#search-tips").children().each(function () {
                        $(this).remove();
                    })
                    $("#search-tips").hide();
                }
            }
        })
    }
</script>